<?php 
/**
 * user model
 * @author Yuwei
 *
 */
final class userModel extends BluePhp_Core_Model
{
	/**
	 * 构造函数
	 */
	public function __construct()
	{
		parent::__construct($this->_tableName);
	}
	
	/**
	 * 表名
	 * @var unknown_type
	 */
	protected $_tableName = 'test';
	
	/**
	 * count
	 */
	public function count()
	{
		return $this->_model->count();
	}
	
	/**
	 * select
	 */
	public function select()
	{
		$back = array();
		$count = $this->count();
		if($count)
		{
			$page = new BluePhp_Library_Page_Adapter($count);
			$list = $this->_model->field('id,name')
								 ->limit($page->limit[0],$page->limit[1])
								 ->select();
			$back = array
			(
				'count' => $count,
				'list' => $list,
				'page' => $page->show()
			);
		}
		return $back;
	}
	
	/**
	 * insert
	 * @param unknown_type $data
	 */
	public function insert($data)
	{
		return $this->_model->data($data)
							->insert();
	}
	
	/**
	 * update
	 * @param unknown_type $data
	 * @param unknown_type $where
	 */
	public function update($data,$where)
	{
		return $this->_model->data($data)
							->where($where)
							->update();
	}
	
	/**
	 * delete
	 * @param unknown_type $where
	 */
	public function delete($where)
	{
		return $this->_model->where($where)
							->delete();
	}
}
?>